import React from "react";

import axios from "axios";

const handleChangeFile = (e:React.ChangeEvent<HTMLInputElement>) => {
  const files = e.target.files
  if(files){
    const uploadFile = files[0];
    const formData = new FormData()
    formData.append(uploadFile.name, uploadFile);
    axios.post("https://www.mocky.io/v2/5cc8019d300000980a055e76",formData,{
      headers:{
        'Content-Type':'multipart/form-data',
      }
    }).then(res => (
      console.log(res)
    ))
  }
}


const App: React.FC = () => {
  return (
    <div className="App" style={{marginTop: '100px', marginLeft: '100px'}}>
      <input type="file" name="myFile" onChange={handleChangeFile}/>

    </div>
  )
}

export default App;


